
var MacUtil={IsSafari:(navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Safari")>=0),IsMSIE:(navigator&&navigator.userAgent&&navigator.userAgent.indexOf("MSIE")>=0),KC_TAB:9,KC_ESC:27,KC_UP:38,KC_DOWN:40,KC_ENTER:13,STYLE_OUTER:"mmaaccOuter",STYLE_STRONG:"mmaaccStrong",STYLE_ITEM:"mmaaccItem",STYLE_ITEMSEL:"mmaaccItemSel",SafeEval:function(s){return eval("["+s+"]")[0];},ParentOffsetSummation:function(elem,prop){var sum=0;while(elem){sum+=elem[prop];elem=elem.offsetParent;}
return sum;},GetLeftOffset:function(r){return MacUtil.ParentOffsetSummation(r,'offsetLeft');},GetTopOffset:function(r){return MacUtil.ParentOffsetSummation(r,'offsetTop');},GetElemWidth:function(elem){return elem.offsetWidth;},GetElemHeight:function(elem){return elem.offsetHeight;},SetElemWidth:function(e,pxWidth){e.style.width=pxWidth+'px';},SetElemHeight:function(e,pxHeight){e.style.height=pxHeight+'px';},ShowElem:function(e){var elem=e;if(typeof e==='string'){elem=MacUtil.GetEl(e);}
if(elem){elem.style.display='';elem.style.visibility='visible';}},HideElem:function(e){var elem=e;if(typeof e==='string'){elem=MacUtil.GetEl(e);}
if(elem){elem.style.visibility='hidden';}},IsHidden:function(e){return(("hidden"==e.style.visibility)||("none"==e.style.display));},clearAll:function(e){while(e.childNodes.length>0){var child=e.childNodes[0];if(child.v2result){child.v2result=null;}
$clearHandlers(child);e.removeChild(child);}},getClientHeight:function(e){while(e&&e.offsetParent){e=e.offsetParent;}
if(MacUtil.IsMSIE)return e['scrollHeight'];else
return e['clientHeight'];},StuffValue:function(stuffElem,stuffVal){if(stuffVal===null||stuffVal===""){return;}
if(stuffElem.nodeName=="SELECT"){for(var i=0;i<stuffElem.childNodes.length;i++){var nOption=stuffElem.childNodes[i];if(nOption.nodeName!="OPTION"){continue;}
if(nOption.childNodes[0].nodeValue==stuffVal){nOption.selected=true;break;}}}
else{stuffElem.value=stuffVal;}},EncodeForUri:function(s){if(encodeURIComponent){return encodeURIComponent(s);}
if(escape){return escape(s);}
return s;},hlstring:function(dispStr,hltext){var idx1=dispStr.toLowerCase().indexOf(hltext.toLowerCase());if(idx1==-1){return dispStr;}
var str2=dispStr.substr(0,idx1);str2=str2+"<b>";str2=str2+dispStr.substr(idx1,hltext.length);str2=str2+"</b>";str2=str2+dispStr.substr(idx1+hltext.length);return str2;},z:0};var MacHttp={GetHttpObject:function(){var httpObj=null;try{httpObj=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e1){try{httpObj=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e2){httpObj=null;}}
if(!httpObj&&typeof XMLHttpRequest!="undefined"){httpObj=new XMLHttpRequest();}
return httpObj;},READYSTATE_UNINITIALIZED:0,READYSTATE_COMPLETED:4,LastHttp:null,SendQuery:function(fullUrl,responseTextHandler){var httpObj=this.LastHttp;if(httpObj!==null&&httpObj.readyState!==MacHttp.READYSTATE_UNINITIALIZED){httpObj.abort();}
httpObj=MacHttp.GetHttpObject();if(httpObj!==null){this.LastHttp=httpObj;httpObj.open("GET",fullUrl,true);httpObj.onreadystatechange=function(){if(httpObj.readyState==MacHttp.READYSTATE_COMPLETED&&httpObj.responseText!==null){responseTextHandler(httpObj.responseText);}};httpObj.send(null);}},z:0};var MacIE={selectElements:null,getSelectElements:function(){if(this.selectElements!==null){return this.selectElements;}
this.selectElements=[];if(document.body){this.findSelects(document.body,this.selectElements);}
return this.selectElements;},findSelects:function(elem,outputArr){if(elem.childNodes){for(var i=0;i<elem.childNodes.length;i++){var cn=elem.childNodes[i];if(cn.nodeName&&cn.nodeName=="SELECT"){outputArr.push(cn);}
this.findSelects(cn,outputArr);}}},hideSelects:function(hideFlag,minTopOffset,maxTopOffset){var mySelects=this.getSelectElements();for(var i in mySelects){var selectNode=mySelects[i];if(hideFlag){if(typeof selectNode.MACWIDTH=='undefined'){selectNode.MACWIDTH=MacUtil.GetElemWidth(selectNode);}
if(MacUtil.GetTopOffset(selectNode)>minTopOffset&&MacUtil.GetTopOffset(selectNode)<maxTopOffset){MacUtil.SetElemWidth(selectNode,0);}}
else{if(typeof selectNode.MACWIDTH!='undefined'){MacUtil.SetElemWidth(selectNode,selectNode.MACWIDTH);}}}},z:0};function MacContext(controlIdArray,serverHandler,minQLen,tabKeySelect,maxResults,onBlurEvent){this.ControlArray=[];for(var ei in controlIdArray){var elem=document.getElementById(controlIdArray[ei]);if(elem!==null){this.ControlArray[ei]=elem;}}
this.PrimaryElement=this.ControlArray[0];if(typeof(AutoCompleteSelClientIds)!=="undefined")
{AutoCompleteSelClientIds[this.PrimaryElement.id]="false";}
this.ContextKey=Math.random().toString().replace(/\./,"");var acel=document.createElement("DIV");acel.className=MacUtil.STYLE_OUTER;acel.style.position="absolute";acel.style.zIndex=11111;acel.id="AutoCompleteElement";acel.setAttribute('selectedByEnterKey','false');MacUtil.HideElem(acel);this._acElem=acel;this.handler=serverHandler;this.resultCache={};this.lastQueryText="";this.queryText="";this.minQueryLength=minQLen;this.tabKeySelect=tabKeySelect;this.dataElements=[];this.maxResults=maxResults;this.onBlurEvent=onBlurEvent;var oThis=this;this.PrimaryElement.onkeyup=function(e){if(MacUtil.IsMSIE){e=window.event;}
else{if(!e){e=window.event;}}
var kc=e.keyCode;var sourceElem=this;var cctx=MacContext.ContextMap[oThis.ContextKey];if(cctx===null){return true;}
MacContext.CurrentContext=cctx;if(kc==MacUtil.KC_TAB||kc==MacUtil.KC_ESC){cctx.Hide();return false;}
if(kc==MacUtil.KC_UP||kc==MacUtil.KC_DOWN){return false;}
if(kc==MacUtil.KC_ENTER){return false;}
cctx.queryText=sourceElem.value;if(sourceElem.value.length<cctx.minQueryLength){cctx.Hide();}
return true;};this.PrimaryElement.onkeypress=function(e){if(MacUtil.IsMSIE){e=window.event;}
else{if(!e){e=window.event;}}
var kc=e.keyCode;if(typeof oThis!="undefined"){var cctx=MacContext.ContextMap[oThis.ContextKey];if(cctx===null){return true;}
if(cctx.EATKEY!==null){if(cctx.EATKEY==kc){cctx.EATKEY=null;return false;}}}
return true;};this.PrimaryElement.onkeydown=function(e){if(MacUtil.IsMSIE){e=window.event;}
else{if(!e){e=window.event;}}
var kc=e.keyCode;var cctx=MacContext.ContextMap[oThis.ContextKey];if(cctx===null){return true;}
MacContext.CurrentContext=cctx;if(kc==MacUtil.KC_UP||kc==MacUtil.KC_DOWN){cctx.UpOrDownSelection((kc==MacUtil.KC_UP));cctx.EATKEY=kc;return false;}
if(kc==MacUtil.KC_ENTER||(kc==MacUtil.KC_TAB&&cctx.tabKeySelect)){if(typeof(document.getElementById('AutoCompleteElement'))!=="undefined"&&document.getElementById('AutoCompleteElement')!==null){document.getElementById('AutoCompleteElement').setAttribute('selectedByEnterKey','false');}
if(!cctx.IsHidden()){cctx.ChooseSelection();if(kc==MacUtil.KC_ENTER){if(typeof(document.getElementById('AutoCompleteElement'))!=="undefined"&&document.getElementById('AutoCompleteElement')!==null){document.getElementById('AutoCompleteElement').setAttribute('selectedByEnterKey','true');}
cctx.EATKEY=MacUtil.KC_ENTER;}}
eval(cctx.onBlurEvent);}
return true;};this.PrimaryElement.onblur=function(){var cctx=MacContext.ContextMap[oThis.ContextKey];if(cctx===null){return;}
if(cctx.SCROLLMODE==1){if(cctx.IsHidden()){eval(cctx.onBlurEvent);}
cctx.Hide();MacContext.CurrentContext=null;return;}
cctx.Hide();MacContext.CurrentContext=null;eval(cctx.onBlurEvent);};this.PrimaryElement.autocomplete='off';MacContext.ContextMap[this.ContextKey]=this;this.SetPosition();}
MacContext.prototype.SetPosition=function(){if(this._acElem){this._acElem.style.left=(MacUtil.GetLeftOffset(this.PrimaryElement)+1)+'px';this._acElem.style.top=(MacUtil.GetTopOffset(this.PrimaryElement)+1)+MacUtil.GetElemHeight(this.PrimaryElement)-1+'px';}
this.PrimaryElement.autocomplete='off';};MacContext.prototype.SetSize=function(){this.SCROLLMODE=null;var clHeight=MacUtil.getClientHeight(this._acElem);var bodyScroll=document.body.scrollTop;var acbottom=this._acElem.offsetTop+MacUtil.GetElemHeight(this._acElem)-bodyScroll;if(acbottom>=clHeight){var adjust=acbottom-clHeight+10;this._acElem.style.overflow="auto";MacUtil.SetElemWidth(this._acElem,MacUtil.GetElemWidth(this._acElem)+20);var ourNewHeight=MacUtil.GetElemHeight(this._acElem)-adjust;ourNewHeight=Math.max(ourNewHeight,60);MacUtil.SetElemHeight(this._acElem,ourNewHeight);this.SCROLLMODE=1;this._acElem.myContext=this;this._acElem.onscroll=function(){this.myContext.SetFocus();return false;};}};MacContext.prototype.SetFocus=function(){this.PrimaryElement.focus();};MacContext.prototype.IsHidden=function(){return MacUtil.IsHidden(this._acElem);};MacContext.prototype.Show=function(){this.SetPosition();if(MacUtil.IsMSIE){MacIE.hideSelects(true,MacUtil.GetTopOffset(this._acElem),MacUtil.GetTopOffset(this._acElem)+MacUtil.GetElemHeight(this._acElem));this.SetFocus();}
MacUtil.ShowElem(this._acElem);};MacContext.prototype.Hide=function(){if(this.IsHidden()){return;}
if(MacUtil.IsMSIE){MacIE.hideSelects(false);}
MacUtil.HideElem(this._acElem);};MacContext.prototype.Clear=function(){MacUtil.clearAll(this._acElem);};MacContext.prototype.GetCurrentSelection=function(){var nodes=this.dataElements;for(var i=0;i<nodes.length;i++){var node=nodes[i];if(node.className==MacUtil.STYLE_ITEMSEL){return i;}}
return-1;};MacContext.prototype.SetCurrentSelection=function(idx){var nodes=this.dataElements;for(var i=0;i<nodes.length;i++){var node=nodes[i];node.className=i==idx?MacUtil.STYLE_ITEMSEL:MacUtil.STYLE_ITEM;}};MacContext.prototype.UpOrDownSelection=function(bUp){var nodes=this.dataElements;if(nodes===null||nodes.length===0){return;}
var idx1=this.GetCurrentSelection();var curidx=idx1+(bUp?-1:1);if(curidx<0){curidx=0;}
if(curidx>=nodes.length){curidx=nodes.length-1;}
if(idx1>=0){nodes[idx1].className=MacUtil.STYLE_ITEM;}
nodes[curidx].className=MacUtil.STYLE_ITEMSEL;this.AdjustScroll();};MacContext.prototype.AdjustScroll=function(){if(this.SCROLLMODE!=1){return;}
var idx1=this.GetCurrentSelection();var elem=this.dataElements[idx1];if(elem.offsetTop+MacUtil.GetElemHeight(elem)-this._acElem.scrollTop>this._acElem.clientHeight){this._acElem.scrollTop+=((elem.offsetTop+MacUtil.GetElemHeight(elem)-this._acElem.scrollTop)-this._acElem.clientHeight);}
if(elem.offsetTop<this._acElem.scrollTop){this._acElem.scrollTop-=(this._acElem.scrollTop-elem.offsetTop);}};MacContext.prototype.ChooseSelection=function(){var idx=this.GetCurrentSelection();if(idx>=0){var node=this.dataElements[idx];var isv2=(typeof node.v2result!='undefined');if(isv2){if(node.v2result.__ist==1){MacUtil.StuffValue(this.PrimaryElement,node.v2result.__d1);if(this.ControlArray.length>1){MacUtil.StuffValue(this.ControlArray[1],node.v2result.__d2);}
if(this.ControlArray.length>2){MacUtil.StuffValue(this.ControlArray[2],node.v2result.__d3);}
this.Clear();this.Hide();}
else{MacUtil.StuffValue(this.PrimaryElement,node.v2result.__disp);this.Clear();this.Hide();}}
else{MacUtil.StuffValue(this.PrimaryElement,node.v2result.__disp);this.Clear();this.Hide();}
if(typeof(AutoCompleteSelClientIds)!=="undefined")
{AutoCompleteSelClientIds[this.PrimaryElement.id]="true";}
if(MacUtil.IsMSIE)
{if(window.event.keyCode!=MacUtil.KC_ENTER)
{this.PrimaryElement.fireEvent("onkeyup");}}
return true;}
if(typeof(AutoCompleteSelClientIds)!=="undefined"&&AutoCompleteSelClientIds!==null)
{AutoCompleteSelClientIds[this.PrimaryElement.id]="false";}
return false;};MacContext.prototype.Populate=function(dispStrings,primaryStrings,secondaryStrings,query,v2results){if(!this._appended){document.body.appendChild(this._acElem);this._appended=1;}
var isv2=(v2results!==null);this._acElem.style.overflow="visible";this._acElem.style.width="";this._acElem.style.height="";var dpeg=document.createElement("DIV");dpeg.style.visibility='hidden';dpeg.style.border='none 0px';dpeg.style.fontSize='0pt';MacUtil.SetElemWidth(dpeg,MacUtil.GetElemWidth(this.PrimaryElement)-1);MacUtil.SetElemHeight(dpeg,0);this._acElem.appendChild(dpeg);var headingComplete=false;var elemArray=[];var elemArraySize=isv2?v2results.length:dispStrings.length;for(var i=-1;i<elemArraySize&&i<this.maxResults;i++){var d=document.createElement("DIV");if(!headingComplete){d.className='macSuggestionHeader';d.innerHTML="Suggestions";headingComplete=true;}
else{d.className=MacUtil.STYLE_ITEM;var tmpstr=MacUtil.hlstring(isv2?v2results[i].__disp:dispStrings[i],query);d.innerHTML=tmpstr;d.acIdx=i;$addHandlers(d,{'mouseover':this.OnMouseOverEvent,'mousedown':this.OnMouseDownEvent});if(isv2){d.v2result=v2results[i];}
else{d.primaryData=dispStrings[i];if(primaryStrings!==null){d.primaryData=primaryStrings[i];}
if(secondaryStrings!==null){d.secondaryData=secondaryStrings[i];}}}
elemArray[i]=d;this._acElem.appendChild(d);}
this.dataElements=elemArray;if(!MacUtil.IsSafari){this.SetSize();}
MacUtil.SetElemWidth(this._acElem,MacUtil.GetElemWidth(this._acElem));this._acElem.removeChild(dpeg);};MacContext.prototype.ForceQuery=function(qtext)
{this.queryText=qtext;};MacContext.prototype.OnMouseDownEvent=function(){if(MacContext.CurrentContext){MacContext.CurrentContext.ChooseSelection();}}
MacContext.prototype.OnMouseOverEvent=function(){if(MacContext.CurrentContext){MacContext.CurrentContext.SetCurrentSelection(this.acIdx);}}
MacContext.prototype.ProcessResult=function(o){var isv2=(typeof o.__v!="undefined"&&o.__v=="2");var query=o.__qu;if(query!=this.queryText){return;}
this.Clear();if(isv2){var v2Results=o.__results;if(v2Results.length>0){this.Populate(null,null,null,query,v2Results);this.Show();}else{if(this.ControlArray.length>1){this.ControlArray[1].value="";}
this.Hide();}}else{var displaystrings=o.__di;var primarystrings=o.__pr;var secondarystrings=o.__se;if(displaystrings.length>0){this.Populate(displaystrings,primarystrings!==null&&primarystrings.length>0?primarystrings:null,secondarystrings!==null&&secondarystrings.length>0?secondarystrings:null,query,null);this.Show();}else{if(this.ControlArray.length>1){this.ControlArray[1].value="";}
this.Hide();}}};MacContext.ContextMap={};MacContext.CurrentContext=null;MacContext.initialized=false;MacContext.pollStarted=0;function __macinit(o)
{if(MacHttp.GetHttpObject()===null){return;}
if(typeof document=="undefined"){return;}
if(typeof document.getElementById=="undefined"){return;}
if(typeof document.createElement=="undefined"){return;}
var elem1=o["elem1"];var elem2=o["elem2"];var elem3=o["elem3"];var handler=o["handler"];var minQuery=o["minQuery"];var tabKeySelect=o["tabKeySelect"];var maxResults=o["maxResults"];var onBlurEvent=o["onBlurEvent"];var controlArray=[];controlArray[0]=elem1;if(elem2!==null&&elem2!==""){controlArray[1]=elem2;}
if(elem3!==null&&elem3!==""){controlArray[2]=elem3;}
var ctx=new MacContext(controlArray,handler,minQuery,tabKeySelect,maxResults,onBlurEvent);if(typeof window.onresize!="function"){window.onresize=function(){for(var x in MacContext.ContextMap){var ctx=MacContext.ContextMap[x];ctx.SetPosition();}};}
if(document.body&&typeof document.body.onclick!="function"){document.body.onclick=function(){for(var x in MacContext.ContextMap){var ctx=MacContext.ContextMap[x];if(!ctx.IsHidden()){eval(ctx.onBlurEvent);ctx.Hide();}}};}
if(MacContext.initialized)
{if(MacContext.pollStarted==0){MacContext.pollStarted=setTimeout("MacLoop()",1000);}}
MacContext.initialized=true;}
function __macDispose()
{if(MacContext.pollStarted!=0)
{clearTimeout(MacContext.pollStarted);MacContext.pollStarted=0;}}
function MacData(s){var o=MacUtil.SafeEval(s);if(!o){return;}
var ctxkey=o.__ck;if(!ctxkey){return;}
var ctx=MacContext.ContextMap[ctxkey];if(!ctx){return;}
if(ctx!=MacContext.CurrentContext){return;}
ctx.resultCache[o.__qu]=o;ctx.ProcessResult(o);}
function MacLoop(){var cctx=MacContext.CurrentContext;if(cctx){if(cctx.lastQueryText!=cctx.queryText&&cctx.queryText.length>=cctx.minQueryLength){var savedResult=cctx.resultCache[cctx.queryText];if(savedResult){cctx.ProcessResult(savedResult);}
else{var encQueryText=MacUtil.EncodeForUri(cctx.queryText);var handlerUri=cctx.handler;handlerUri=handlerUri+(handlerUri.indexOf("?">-1)?"&":"?");handlerUri=handlerUri+"ck="+cctx.ContextKey;handlerUri=handlerUri+"&q="+encQueryText;handlerUri=handlerUri+"&mr="+cctx.maxResults;MacHttp.SendQuery(handlerUri,MacData);}}
cctx.lastQueryText=cctx.queryText;}
MacContext.pollStarted=setTimeout("MacLoop()",250);return true;}
;
